package com.woniu.outlet.dao;

import com.woniu.outlet.po.OrderPo;
import com.woniu.outlet.po.OrderPoExample;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface OrderPoMapper {
    long countByExample(OrderPoExample example);

    int deleteByExample(OrderPoExample example);
    int deleteByPrimaryKey(Long id);

    int insert(OrderPo record);
    int insertSelective(OrderPo record);

    List<OrderPo> selectByExample(OrderPoExample example);
    OrderPo selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("record") OrderPo record, @Param("example") OrderPoExample example);
    int updateByExample(@Param("record") OrderPo record, @Param("example") OrderPoExample example);
    int updateByPrimaryKeySelective(OrderPo record);
    int updateByPrimaryKey(OrderPo record);

    //查询订单明细(根据订单编号)
    List<OrderPo> selectOrderDetailByOrderNo(String orderNo);

    //删除订单(根据订单编号)
    @Delete("delete from ERP_order where order_no = #{orderNo}")
    void deleteByOrderNo(String orderNo);

    //查询订单明细(根据订单id)
    List<OrderPo> selectOrderDetailById(Long id);

    //查询定向信息(根据订单orderCreater)
    @Select("select * from ERP_order where order_creater = #{orderCreater}")
    OrderPo selectByOrderCreater(String orderCreater);

    @Select("select * from ERP_order where order_no = #{orderNo}")
    OrderPo selectOrderPoByOrderNo(String orderNo);

    @Update("update ERP_order set order_status = #{orderStatus} where order_no = #{orderNo}")
    void updateStatus(OrderPo orderPo);

    @Update("update ERP_order set order_status = #{orderStatus} where order_no = #{orderNo}")
    void updateStatusByOrderNo(@Param("orderNo") String orderNo,@Param("orderStatus")String orderStatus);

    @Select("select id from ERP_order where order_no =#{orderNo}")
    Long selectIdByOrderNo(String orderNo);
}